from sqlalchemy import Column, Integer, String, Sequence, or_
from sqlalchemy.orm import Session

from app.db import db_query, db_update, Base


class ArchivePage(Base):
    """
    档案图片页表
    """
    # ID
    id = Column(Integer, Sequence('id'), primary_key=True, index=True)

    archive_id = Column(Integer)
    # 分类名
    name = Column(String)

    # 分类名(显示)
    name_display = Column(String)

    @staticmethod
    @db_query
    def get_by_archive_id(db: Session, archive_id: int):
        return db.query(ArchivePage).filter(ArchivePage.archive_id.__eq__(archive_id)).all()

    @db_update
    def delete_by_archive_id(self, db: Session, archive_id: int):
        return db.query(ArchivePage).filter(ArchivePage.archive_id.__eq__(archive_id)).delete()
